package com.gts.sofa.controller;

import com.gts.sofa.anotation.MyAnotation;
import com.gts.sofa.dao.BookDao;
import com.gts.sofa.pojo.Boss;
import com.gts.sofa.pojo.Car;
import com.gts.sofa.pojo.Color;
import com.gts.sofa.pojo.Red;
import com.gts.sofa.service.MyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Mycontroller {

    @Autowired
    MyService myService;

    @Autowired
    Boss boss;

    @Autowired
    Color color;


    @Autowired
    Red red;

    @RequestMapping("/hello")
    public String hello(){
        String name =  myService.sayHello("tomcat");
        System.out.println(name);
        return "name";
    }




    @MyAnotation
    @RequestMapping("/hello1")
    @ResponseBody
    public String hello1(){

        String name =  myService.sayHello("tomcat");
        System.out.println(name);
        return name;
    }



    @RequestMapping("/hello2")
    @ResponseBody
    public String hello2(){
        boss.run();
        Car car = boss.getCar();
        car.setColor("block");
        System.out.println(boss.toString());

        System.out.println(color.toString());

        return "success";
    }




    @RequestMapping("/hello3")
    @ResponseBody
    public String hello3(){

        color.carRun();

        return "success";
    }



    @RequestMapping("/hello4")
    @ResponseBody
    public String hello4(){

        red.test();
        Car car = color.getCar();
        System.out.println(car.getColor());

        return "success";
    }

}
